<template>
	<view class="content bg-white">
		<image class="logo" src="http://wx.qdhansen.com/images/logo.jpg"></image>
		<view class="text-area">
			<text class="title">
				瀚生电子签
			</text>
		</view>
		<view class="" style="height: 66rpx;">

		</view>
		<view class="cu-list menu solids-top solids-bottom">
			<view class="cu-item" style="padding: 0px;">
				<view class="content padding-tb-sm">
					<view style="font-size: 26rpx;" class="text-bold"><text style="color: #408af3;">瀚生电子签</text> <text
							class="margin-left-xs"> 申请</text></view>
					<view class="text-gray text-sm">
						<text class="cuIcon-infofill margin-right-xs"></text>获取你的头像、昵称、地区及性别
					</view>
				</view>
				<view class="action">
					<icon type="info" size="26" color="#67ae62" />
				</view>
			</view>
		</view>

		<view class="cu-list menu-avatar">
			<view class="cu-item" style="padding: 0px;">
				<view class="cu-avatar round lg userinfo-avatar">
					<open-data type="userAvatarUrl"></open-data>
				</view>
				<view class="content">
					<view class="title">
						<open-data type="userNickName"></open-data>
					</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">
							微信个人信息
						</view>
					</view>
				</view>
				<view class="action">
					<icon type="success_no_circle" size="26" color="#67ae62" />
				</view>
			</view>
		</view>

		<view class="bg-white margin-top">
			<view class="flex">
				<view url="/pages/index/index" class="flex-sub padding-sm margin-xs radius">
					<navigator url="/pages/index/index" open-type="switchTab" class="cu-btn block lg line-blue">取消</navigator>
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					<button class="cu-btn block bg-blue lg" @click="login">允许</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var that
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {
			that = this			
		},
		onShow() {
			uni.login({
				provider: 'weixin',
				success: function(loginRes) {
					that.$u.post('index/openid', {
						code: loginRes.code
					}).then(res => {
						uni.setStorageSync('token', res.openid);
					})
				}
			});
		},
		methods: {
			login() {				
				wx.getUserProfile({
					desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
					success: (res) => {
						that.$u.post('index/openid', res).then(res => {
							uni.reLaunch({
								url:'../index/index'
							})
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		padding: 30rpx;
	}

	.logo {
		height: 134rpx;
		width: 134rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 41rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #000000;
	}

	.userinfo-avatar {
		overflow: hidden;
		display: block;
		width: 100rpx;
		height: 100rpx;
		border-radius: 10%;
	}
</style>
